<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@ page session="true" %>
<%@ page import="javax.portlet.*" %>
<%@page import ="rai.dto.*" %>
<%@page import ="rai.dao.*" %>
<%@page import = "java.util.*" %>

<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<portlet:defineObjects/>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Personal Information Tracking System</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<script type="text/javascript" src='<%= request.getContextPath() + "/js/calendarDateInput.js" %>'></script>
<script type="text/javascript">
    function getForm(namespace, name) {
        return document.forms[namespace + name];
    }
    function back_to_emp_info_form(namespace, name) {
        var frm = getForm(namespace, name);
        frm.txtAction.value = "back_to_empInfo_form_2";
        frm.submit();
    }
    function back_to_login(namespace, name) {
		var frm = getForm(namespace, name);
		frm.txtAction.value = "back_to_login_form";
		frm.submit();
	}
	function update_taken_course_info(namespace,name){
		var frm = getForm(namespace, name);
		frm.txtAction.value = "update_taken_course_info";
		frm.submit();
		}
	
</script>
<link href='<%=request.getContextPath() + "/css/style.css" %>' rel="stylesheet" type="text/css" media="screen" />
</head>

<body>
<form name="<portlet:namespace/>edittkncourseForm" action="<portlet:actionURL/>" method="POST">
<input type="hidden" name="txtAction" />
<table align="center">
	<tr class="title">
			<td colspan="2">		
					<h1><a href="#">Personal information tracking system </a></h1>
					<p>exploit the value of data</p>
					<hr />

			</td>
	</tr>
	<%TakenCourseDTO CourseInfo = (TakenCourseDTO) session.getAttribute("TakenCourseInfo"); %>
	<%String succMess = (String) session.getAttribute("succMess"); %>
	<tr class="title">
			<td colspan="2" align="left"> Welcome, <font color="orange"/><b>[${sessionScope.role}]${sessionScope.name}</b></font>
		| <a href="#" onclick="back_to_emp_info_form('<portlet:namespace/>','edittkncourseForm')">Home</a>
		| <a href="#" onclick="back_to_login('<portlet:namespace/>','edittkncourseForm')">Logout</a>
			
	   </td>
	</tr>

	
	<tr>	
		<td>
			<table border="1">
				<tr>
					<td><h2 class="title">Course  Information</h2></td>
				</tr>
					
				<tr>
					<td><em>General Information </em></p></td>

				</tr>
				<tr>
					<td>
						<table border="1" width="100%">							
							<tr>
							  <td align="left" valign="bottom">&nbsp;Name&nbsp;</td>
							  <td align="left" valign="middle" colspan="2"><%=CourseInfo.getSname() %></td>
							</tr><tr>

							  <td align="left" valign="bottom">&nbsp;Description&nbsp;</td>
							  <td align="left" valign="middle" colspan="2"><%=CourseInfo.getDes() %></td>
							</tr>
							<tr>
							  <td align="left" valign="bottom">&nbsp;Department/Institute Issued &nbsp;</td>
							  <td colspan="2" align="left" valign="middle"><%=CourseInfo.getDept() %></td>							
						  </tr>

						  <tr>
							  	<td align="left" valign="bottom">&nbsp;Training Period</td>
						  		<td colspan="2" align="left" valign="middle"><%=CourseInfo.getPeriod() %></td>
						  </tr>
							<tr>
							  <td align="left" valign="middle">&nbsp;Date Issued &nbsp;</td>
							  <td colspan="2" align="left" valign="bottom">&nbsp;
							<%String path = request.getContextPath();%>
							  <script> DateInput('periodFrom', true, 'DD/MM/YYYY','<%=path%>','<%=CourseInfo.getDate()%>');</script></td>
						  </tr>
						  <tr>
							  <td align="left" valign="bottom">&nbsp;Grade&nbsp;</td>
							  <td align="left" valign="bottom">								  
								  <select name="lstGrade" onchange="if(this.value=='Other'){
														this.form.otherGrade.style.visibility='visible';
														this.form.otherGrade.focus();}
												else{this.form.otherGrade.style.visibility='hidden';}"
								  > 
								  	<%EditTakenCourseInfoDAO dao = new EditTakenCourseInfoDAO();
								  	  List<GradeDTO> grade = new ArrayList<GradeDTO>(); 
								  	  grade=dao.getGrade();
								  	  for(int i=0;i<grade.size();i++){
								  		  
								  	  if(grade.get(i).getGrade().equals(CourseInfo.getGrade())){%>
								  	  	<option selected value='<%=grade.get(i).getGrade()%>'><%=grade.get(i).getGrade()%></option>
								  	  <%}else{%>
								  	  	<option value='<%=grade.get(i).getGrade()%>'><%=grade.get(i).getGrade()%></option>
								  	  <%}}%>
                                  </select>
					            <input name="otherGrade" type="text" style="visibility:hidden" />								</td>
							
						  </tr>

						  <tr align="left" valign="bottom">
						  	  <td colspan="4"><input type="button" name="btnUpdate" value="Update" onclick="update_taken_course_info('<portlet:namespace/>','edittkncourseForm')"/><input type="button" name="btnCancel" value="Cancel" onclick="back_to_emp_info_form('<portlet:namespace/>','edittkncourseForm')"/><%=succMess %></td>

						  </tr>
				    </table>					</td>
				</tr>
			</table>			
		</td>
	</tr>
	<tr>
		<td colspan="2">
			<div style="clear: both;">&nbsp;</div>

			<div id="footer"><p>Development by HCMUT-Group3.</p>
			</div>
		</td>
	</tr>
</table>
</form>
</body>

